//
//  UIView+IBInspectable.swift
//  MYWeibo
//
//  Created by Magic Yu on 16/4/13.
//  Copyright © 2016年 Magic Yu. All rights reserved.
//

import UIKit

extension UIView {

    //设置圆角
    @IBInspectable var cornerRadius: CGFloat {
    
        get {
            return layer.cornerRadius
        }
        set {
            layer.cornerRadius = newValue
            //设置masktobounds
            if cornerRadius > 0 {
            layer.masksToBounds = true
            }else {
            layer.masksToBounds = false
            }
        }
    }
    
    //设置外边框
    @IBInspectable var borderWidth: CGFloat {
    
        get {
        return layer.borderWidth
        }
        
        set {
        layer.borderWidth = newValue
        }
        
    }
    
    //设置外边框颜色
    @IBInspectable var borderColor: UIColor? {
    
        get {
            if let c = layer.borderColor{
        return UIColor(CGColor: c)
            }
            return nil
        }
        
        set {
        layer.borderColor = newValue?.CGColor
        }
        
    }
    
}




